package util

import (
	"github.com/bwmarrin/snowflake"
)

var SnowFlakeNodeEntity *SnowFlakeNode

func init() {
	conf := Config()
	nodeId := conf.MustInt64("node","id",1)

	snode,_  := snowflake.NewNode(nodeId);
	SnowFlakeNodeEntity = &SnowFlakeNode{node:snode}
}

type SnowFlakeNode struct {
	node *snowflake.Node
}

func (node *SnowFlakeNode) GenerateNewId () int64 {
	return node.node.Generate().Int64()
}


